package WWW.SST.LIB;

/** 
 TicketPost ��ժҪ˵����
*/
public class TicketPost extends MOLE.App.Every
{
	public int TicketId = 0;
	public String TicketIdX;
	private int Times = 0;
	private int Result = 0;
	public TicketPost(int ticketid)
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
		TicketId = ticketid;

		String s = " select * from  daigouPostStatus where dpTicketId=" + TicketId;
		DataTable d = MOLE.SQL.GetDataTable(s);

		{
			Times = Integer.parseInt(d.Rows[0]["dpTimes"].toString());
			Result = Integer.parseInt(d.Rows[0]["dpResult"].toString());
		}

	}

	public TicketPost()
	{

	}


	public final void Add()
	{

		MOLE.SQLOS o = new MOLE.SQLOS("daigouPostStatus");
		o.RS("dpTicketId", this.TicketId);
		o.RS("dpTicketIdX", this.TicketIdX);
		o.Insert();

	}

	public static void AddArr(String ticketids, String timestamp)
	{
		MOLE.SQLOS o = new MOLE.SQLOS("DaigouPost_Add");
		o.RS(ticketids);
		o.RS(timestamp);
		o.ExecStoreProcess();
	}

	/** 
	 set Receive result
	 
	 @param reseult
	*/
	public final void SetResult(int reseult)
	{
		try
		{
			MOLE.SQLOS o = new MOLE.SQLOS("daigouPostStatus");
			o.RS("dptimes", this.Times + 1);
			o.RS("dpresult", reseult);
			o.Update("dpTicketId", TicketId);
		}
		catch (RuntimeException ee)
		{
			this.StausCode = 1;
			this.StausMsg = ee.toString();
		}
	}


	/** 
	 set Receive result
	 
	 @param ticketIds
	 @param result
	*/
	public static void SetResults(String ticketIds, int result)
	{
		String[] s = ticketIds.split("[,]", -1);
		for (int i = 0;i < s.length;i++)
		{
			int id = Integer.parseInt(s[i]);
			TicketPost o = new TicketPost(id);
			o.SetResult(result);
		}
	}

	public final void SetProcessResult(String statuscode, String statusmsg)
	{

		MOLE.SQLOS o = new MOLE.SQLOS("DaigouPost_SetProcessResult");
		o.RS(this.TicketId);
		o.RS(statuscode);
		o.RS(statusmsg);
		o.ExecStoreProcess();
	}


}